package com.ruicar.afs.cloud.image.service;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruicar.afs.cloud.image.condition.AuditCondition;
import com.ruicar.afs.cloud.image.condition.ImageCondition;
import com.ruicar.afs.cloud.image.condition.ShowFileCondition;
import com.ruicar.afs.cloud.image.entity.ComAttachmentFile;
import com.ruicar.afs.cloud.image.entity.ComAttachmentManagement;
import com.ruicar.afs.cloud.image.vo.AuditFileStatusVo;
import com.ruicar.afs.cloud.image.vo.AuditFileVo;
import com.ruicar.afs.cloud.image.vo.UploadInputVo;
import org.springframework.validation.annotation.Validated;

import java.io.File;
import java.util.List;

/**
 * @Description:
 * @Author: fangchenliang
 * @Date: 2020/6/4 19:33
 */
public interface ComAttachmentFileService extends IService<ComAttachmentFile> {

    List<ComAttachmentFile> findUploadFileByBusiNo(String busiNo, List busiNodes);

    /**
     * @Description: 保存影像文件相关信息
     * @Author: fangchenliang
     * @Date: 2020/6/11 18:47
     * @Param: [uploadInputVo]
     * @Return: void
     */
    ComAttachmentFile saveComAttachmentFile(UploadInputVo uploadInputVo);

    /**
     * @Description:文件合成之后上传文件至OSS
     * 该方法没有删除临时文件
     * @Author: fangchenliang
     * @Date: 2020/6/28 13:49
     * @Param: [file, uploadInputVo]
     * @Return: void
     */
    ComAttachmentFile storeFileToOss(File file, UploadInputVo uploadInputVo);

    /**
     * 获取远端模板
     *
     * @param vo
     * @return
     */
    public byte[] getComAttachmentFile(@Validated UploadInputVo vo);

    /**
     * 获取影像审核页面-初始化数据
     */
    public List<AuditFileVo> getAllFileList(AuditCondition auditCondition);
    /**
     * 获取历史版本号
     */
    List<String> getHistoryVersion(String busiNo,String busiNode,String attachmentCode);

    /**
     * 获取附件信息预览路劲
     *
     * @param applyNo
     * @param belongNo
     * @param typeData
     * @return
     */
    ComAttachmentManagement downloadFileByType(String applyNo, String belongNo, String typeData);
    ComAttachmentManagement showFileByType(ShowFileCondition showFileCondition);
    String getAuthorization();

    ComAttachmentFile updateFileStatus(AuditFileStatusVo vo);

    List<ComAttachmentFile> getDealerSign(String applyNo);

    /**
     * 通过id下载合同影像资料
     *
     * @param attachmentFile
     * @return
     */
    public byte[] downloadAttachmentFile(ComAttachmentFile attachmentFile);

    /**
     * 修改文件状态
     * @param busiNo
     * @return
     */
    void updateFileStatusByBusiNo(String busiNo);

    /**
     * 修改文件历史版本
     * @param busiNo
     * @return
     */
    void updateFileVersionByBusiNo(String busiNo,String busiNode);

    void updateFileStatusForLoan(String contractNo,List<String> attachmentIdList);

    IPage<List<ComAttachmentFile>> getComAttachMentFileByPage(Page page, ImageCondition condition);

    /**旋转保存文件*/
    JSONObject revolveFile(String md5, String fileName, String fileType, int degree);

    byte[] downloadFileBytes(String md5);

    /**
     * 获取最新合同模板数据
     * @param attachmentCode
     * @param busiNo
     * @param belongNo
     * @return
     */
    public ComAttachmentFile getNewAttachmentFile(String attachmentCode, String busiNo, String belongNo);
}
